<?php

class ArticlesController extends AdminBase{

    public function actionIndex()
    {
        $this->baseIndex('ArticlesModel');
    }

    public function actionDelete($id)
    {
        $this->loadModel($id)->delete();
        $this->success('删除成功'); 
    }

    public function actionCreate(){
        //百度编辑器的一个字段，字段名不能用有包含中括号的。
       if(IS_POST){
         if(isset($_POST['Contnet'])){
            $_POST['ArticlesModel']['Contnet'] = $_POST['Contnet'];
         }
       }
       $this->baseCreate('ArticlesModel');  
    }
    public function actionUpdate(){
       if(IS_POST){
         if(isset($_POST['Contnet'])){
            $_POST['ArticlesModel']['Contnet'] = $_POST['Contnet'];
         }
       }        
        $this->baseUpdate('ArticlesModel');
    }

    public function loadModel($id)
    {
        $model=ArticlesModel::model()->findByPk($id);
        if($model===null)
            $this->error('找不到记录');
        return $model;
    }    
}